Skip to content

feat(ezc): named return variables#1187

Merged
SchoolyB merged 1 commit intov3.0.0from
ezc/named-returns
Mar 22, 2026
Merged

feat(ezc): named return variables#1187
SchoolyB merged 1 commit intov3.0.0from
ezc/named-returns

Conversation

@SchoolyB
Copy link
Owner

Summary

Implements named return variables, the last major function feature.

What's new

  • Parse return param names: -> (area int), -> (x int, y int), -> (min, max int)
  • Store names in AST alongside types
  • Emit local variable declarations at function entry for named returns
  • Register named return vars in type checker scope with correct types
  • Fix inline block scoping: multi-var expansion blocks no longer create new scope, so unpacked variables remain visible to subsequent statements (fixes string interpolation of unpacked values)

Example

do swap(a int, b int) -> (x int, y int) {
    x = b
    y = a
    return x, y
}

Generates:

EzMulti_swap ez_fn_swap(int64_t a, int64_t b) {
    int64_t x;
    int64_t y;
    x = b;
    y = a;
    return (EzMulti_swap){x, y};
}

Results

10/14 basic examples now pass (up from 9)

  • functions.ez is newly passing
  • 85/85 tests still passing

Test plan

  • Named single return: -> (area int)
  • Named multi return: -> (x int, y int)
  • Shared type return: -> (min, max int)
  • Named return vars usable in function body
  • Multi-var unpacking + interpolation works
  • All 85 existing tests pass
  • functions.ez compiles and runs correctly

Parse and store return parameter names in the AST alongside types.
Emit local variable declarations at function entry for named returns.
Register named return vars in type checker scope.

Fixes inline block scoping so multi-var unpacked variables remain
visible to subsequent statements.

Unblocks functions.ez (now 10/14 examples passing).
@SchoolyB SchoolyB changed the title feat(ezc): named return variables — functions.ez passes feat(ezc): named return variables Mar 22, 2026
@SchoolyB SchoolyB merged commit 5fba44b into v3.0.0 Mar 22, 2026
2 checks passed
@SchoolyB SchoolyB deleted the ezc/named-returns branch March 22, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant